{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.neighbors import KNeighborsRegressor\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.colors import ListedColormap\n",
    "%matplotlib inline\n",
    "from sklearn import datasets\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.093949  ],\n       [0.10109199],\n       [0.35518029],\n       [0.4356465 ],\n       [0.59137213],\n       [0.71676644],\n       [1.32277806],\n       [1.91720759],\n       [2.0733097 ],\n       [2.118274  ],\n       [2.18793606],\n       [2.28075166],\n       [2.30739681],\n       [2.60924161],\n       [2.6444746 ],\n       [2.72441591],\n       [2.74406752],\n       [2.84022281],\n       [2.84216974],\n       [3.01381688],\n       [3.06047861],\n       [3.08466998],\n       [3.08817749],\n       [3.19960511],\n       [3.22947057],\n       [3.4091015 ],\n       [3.57594683],\n       [3.87116845],\n       [3.89078375],\n       [3.90264588],\n       [3.95862519],\n       [3.99579282],\n       [4.16309923],\n       [4.35006074],\n       [4.458865  ],\n       [4.62798319],\n       [4.71874039],\n       [4.72334459],\n       [4.8183138 ],\n       [4.89309171]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(0) #设置随机数种子\n",
    "x = np.sort(5*np.random.rand(40,1),axis=0)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.09381086,  0.10091989,  0.34775941,  0.4219966 ,  0.55750066,\n        0.65695022,  0.96940081,  0.94059723,  0.87637482,  0.8538402 ,\n        0.81553704,  0.75839099,  0.74075654,  0.50756044,  0.47689441,\n        0.40518094,  0.38713765,  0.29682859,  0.29496884,  0.12742837,\n        0.08102512,  0.05689193,  0.05338977, -0.05797992, -0.08776485,\n       -0.26432971, -0.42082464, -0.66655347, -0.68104667, -0.68968448,\n       -0.72911815, -0.75404581, -0.85289554, -0.93507411, -0.96803456,\n       -0.99643995, -0.99997983, -0.99993999, -0.99439521, -0.98371764])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = np.sin(x).ravel()\n",
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "y[::5] +=1*(0.5-np.random.rand(8)) #破坏数据的整齐"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
